package com.yzh.grainmall.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yzh.grainmall.common.valid.AddGroup;
import com.yzh.grainmall.common.valid.ListValue;
import com.yzh.grainmall.common.valid.UpdateGroup;
import com.yzh.grainmall.common.valid.UpdateStatusGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;
import java.io.Serializable;

/**
 * 品牌
 * 
 * @author yzh
 * @email 164949413@qq.com
 * @date 2021-05-26 08:52:53
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 * groups 在不同条件下出发的，
	 *     为注解标注了适用于哪一种情况才去校验
	 */
	@NotNull(message = "修改的时候，必须指定品牌id!", groups = {UpdateGroup.class})//修改的时候 不能为空
	@Null(message = "新增的时候，不能指定品牌id!", groups = {AddGroup.class})//新增的时候 必须为空
	@TableId
	private Long brandId;
	/**
	 * 品牌名
	 */
	@NotBlank(message = "品牌名必须提交", groups = {AddGroup.class, UpdateGroup.class})
	private String name;
	/**
	 * 品牌logo地址
	 */
	@NotBlank(groups = {AddGroup.class})
	@URL(message = "品牌logo地址必须为合法的url地址", groups = {AddGroup.class, UpdateGroup.class})
	private String logo;
	/**
	 * 介绍
	 */
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@NotNull(groups = {AddGroup.class})
	@ListValue(values = {0, 1}, groups = {AddGroup.class, UpdateStatusGroup.class})
	private Integer showStatus;
	/**
	 * 检索首字母
	 */
	@NotBlank(groups = {AddGroup.class})
	@Pattern(regexp = "^[a-zA-Z]$", message = "检索首字母需要是一个字母！", groups = {AddGroup.class, UpdateGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(groups = {AddGroup.class})
	@Min(value = 0, message = "排序需要大于等于0", groups = {AddGroup.class, UpdateGroup.class})
	private Integer sort;

}
